//
//  TGMerchantController.m
//  GroupBuy
//
//  Created by wwj on 15/11/12.
//  Copyright © 2015年 wwj. All rights reserved.
//

#import "TGMerchantController.h"
#import "TGDealModel.h"
#import "TGBusinessModel.h"

@interface TGMerchantController ()<UIWebViewDelegate>
@property (strong, nonatomic) UIWebView *webView;
@property (assign, nonatomic) BOOL flag;
@end

@implementation TGMerchantController

-(void)setModel:(TGDealModel *)model{
    _model = model;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = kBgColor;
    
    _webView = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    _webView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
    _webView.delegate = self;
    _webView.backgroundColor = kBgColor;
    self.view = _webView;
    
    
    
    NSString *urlStr = [_model.businesses.firstObject h5_url];
    
    NSURL *url = [NSURL URLWithString:urlStr];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [_webView loadRequest:request];
    
    
}

-(void)webViewDidStartLoad:(UIWebView *)webView{
    [MBProgressHUD showMessage:@"加载中..." toView:_webView];
}

-(void)webViewDidFinishLoad:(UIWebView *)webView{
    [MBProgressHUD hideAllHUDsForView:_webView animated:YES];
    webView.scrollView.contentInset = UIEdgeInsetsMake(70, 0, 0, 0);
    NSString *str = [webView stringByEvaluatingJavaScriptFromString:@"(document.getElementsByTagName('html')[0]).innerHTML"];
    MyLog(@"\n%@", str);
    _flag = FALSE;
    _flag = TRUE;
}

@end
